/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cassandrawindow;

import java.util.*;
import java.text.*;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

/**
 *
 * @author quyennb
 * Tinh tong so key trong trong redis
 * Sau do tao moi connect voi redis de lay 10000 keys
 *
 */
public class GetRedisPushCassandra {
    public static void main(String[] args) throws ParseException {
          //get all key from redis]
          ThreadHandleCountClick tcc = new ThreadHandleCountClick();
          //HandleCountClick hcc = new HandleCountClick();
          //hcc.handleData();
    }
    public static long longToDate(String str) throws ParseException
    {
        SimpleDateFormat df = (SimpleDateFormat) SimpleDateFormat.getInstance();
        df.applyPattern("dd/MM/yyyy");
       // Date date = df.parse("11/2/2008 00:00:00");

        Date date = df.parse(str);
        //System.out.println(date);
        Calendar cal = new GregorianCalendar();
        cal.setTime(date);
        //System.out.println(cal.getTimeInMillis()/1000);
        return cal.getTimeInMillis()/1000;
    }
    public static long dataToLong(String keyHandle) throws ParseException
    {
        long epoch = 0;
        String[] arr ;
        String[] hoursplit ;
        try {
                arr = keyHandle.split(" ");

                if(arr.length >= 2)
                {
                    hoursplit = arr[1].split("-");
                    String time =  arr[0] + " " + hoursplit[0] + ":00:00";
                    epoch = new java.text.SimpleDateFormat ("yyyy-MM-dd HH:mm:ss").parse(time).getTime()/1000;
                } else {
                    hoursplit = arr[0].split("-");
                    String time =  hoursplit[0] + "-" + hoursplit[1] + "-" + hoursplit[2];
                    epoch = new java.text.SimpleDateFormat ("yyyy-MM-dd").parse(time).getTime()/1000;
                }
        } catch(Exception ex ) {
            Debug.println(ex.getMessage());
        }
                            
      return epoch;
    }
}
